package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.LogisticsConfig;
import com.xinhe.web.request.ServiceCenterQuery;
import com.xinhe.web.service.AliyunService;
import com.xinhe.web.service.LogisticsConfigService;
import com.xinhe.web.service.ServiceCenterService;
import com.xinhe.web.util.ValidatorUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

@Api(value = "物流配置", tags = {"物流配置"})
@RestController
@RequestMapping(value = {"/logisticsConfig"}, produces = {"application/json;charset=UTF-8"})

public class LogisticsConfigController {
    @Autowired
    private LogisticsConfigService logisticsConfigService;

    @ApiOperation(httpMethod = "GET", value = "分页查询物流配置")
    @RequestMapping({"/pageLogisticsConfig"})
    public QueryResults<LogisticsConfig> pageLogisticsConfig(Long userId, Integer freeFreight, int pageNum, int pageSize) {
        return this.logisticsConfigService.pageLogisticsConfig(userId,freeFreight,pageNum,pageSize);
    }

    @ApiOperation(httpMethod = "POST", value = "保存物流配置")
    @RequestMapping({"/saveLogisticsConfig"})
    public Result saveLogisticsConfig(Long userId, Integer freeFreight,BigDecimal freightFee,String remark) {
        return this.logisticsConfigService.saveModel(userId,freeFreight,freightFee,remark);
    }

    @ApiOperation(httpMethod = "GET", value = "删除物流配置")
    @ApiImplicitParam(name = "logisticsConfigId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteLogisticsConfig"})
    public Result deleteLogisticsConfig(Long logisticsConfigId) {
        return this.logisticsConfigService.delete(logisticsConfigId);
    }

    @ApiOperation(httpMethod = "GET", value = "物流配置详情")
    @ApiImplicitParam(name = "logisticsConfigId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailLogisticsConfig"})
    public Result detailLogisticsConfig(Long logisticsConfigId) {
        return this.logisticsConfigService.findById(logisticsConfigId);
    }
}
